<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<jsp:directive.page import="com.sun.java.swing.plaf.windows.resources.windows"/>
<%
String path1 = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path1+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'up.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%@ page import="java.util.*,java.io.*"%>

<%
String path=request.getParameter("uploadfile");
out.println("path:"+path);
String newPath="";
int count=0;

if(path!=null)
{
ArrayList arr=new ArrayList();
StringTokenizer st=new StringTokenizer(path,"\\");
while(st.hasMoreTokens())
{
arr.add(count,st.nextToken());
count++;
}
// create ur own path
String original_path=new File("..").getCanonicalPath();
String created_path=original_path+"\\server\\default\\deploy\\container.war\\images\\";
newPath=created_path+""+arr.get(count-1);
int c;
FileInputStream fis=new FileInputStream(path);
FileOutputStream fos=new FileOutputStream(newPath);
while((c=fis.read())!=-1)
{
fos.write((char)c);
}
response.sendRedirect("EmpRegistration.jsp?image_name="+arr.get(count-1));
}

out.println("Thanks for using");
out.println("<br>");
out.println("<br>");
out.println("1.File1 Uploaded from :: "+path);
out.println("<br>");
out.println("<br>");
out.println("2.Uploaded File1 is Saved in :: "+newPath);


%>

  </body>
</html>
